/*
 * @Description:批量导入路由
 * @Author: Chenx
 * @Date: 2023-04-11 15:48:19
 * @LastEditors: Chenx
 * @LastEditTime: 2023-04-13 10:36:38
 */
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'

const constantFiles = require.context('./modules', true, /\.ts$/)

let routes: Array<RouteRecordRaw> = []
// 根据路径拿到所有modules文件夹下的ts文件
constantFiles.keys().forEach((key) => {
  routes = routes.concat(constantFiles(key).default)
})

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
